package com.yanqu.road.entity.activity;

import com.yanqu.road.entity.DataObject;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ServerMallBuyRecordUserData extends DataObject {
    private long userId = 0L;

    // key:mallId
    private Map<Integer, ServerMallBuyRecordDayData> recordDataList = new ConcurrentHashMap<>();

    public ServerMallBuyRecordUserData() {
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public Map<Integer, ServerMallBuyRecordDayData> getRecordDataList() {
        return recordDataList;
    }

    public void setRecordDataList(Map<Integer, ServerMallBuyRecordDayData> recordDataList) {
        this.recordDataList = recordDataList;
    }

    public ServerActivityMallDayBuyData getServerMallBuyRecordData(int mallId, int day){
        ServerMallBuyRecordDayData userData = recordDataList.get(mallId);
        if(userData == null){return null;}
        return userData.getRecordDataList().get(day);

    }

    public void setServerMallBuyRecordData(int mallId, int day, ServerActivityMallDayBuyData data){
        ServerMallBuyRecordDayData userData = recordDataList.get(mallId);
        if(userData == null){
            ServerMallBuyRecordDayData newData = new ServerMallBuyRecordDayData();
            newData.getRecordDataList().put(day, data);
            recordDataList.put(mallId, newData);
        } else{
            userData.getRecordDataList().put(day, data);
        }
    }
}
